<template>
  <van-nav-bar v-bind:title="title" v-bind:fixed="fixed" v-bind:left-arrow="back" @click-left="onClickLeft" v-bind:right-text="rightText" @click-right="onClickRight"/>
</template>
<script>
export default {
  name: 'NavBar',
  props: {
    title: {
      type: String
    },
    fixed: {
      type: Boolean,
      default: false
    },
    back: {
      type: Boolean,
      default: false
    },
    url: {
      type: String
    },
    rightText: {
      type: String
    },
    rightUrl: {
      type: String
    }
  },
  methods: {
    onClickLeft: function () {
      this.$router.goBack()
      if (this.url != null) {
        this.$router.push(this.url)
      } else {
        this.$router.go(-1)
      }
    },
    onClickRight: function () {
      if (this.rightUrl != null) {
        this.$router.push(this.rightUrl)
      }
    }
  }
}
</script>
